Vue 项目中的nginx配置

history模式下 配置rewrite规则

1
2
3
location / {
try_files $uri $uri/ /index.html;
}

配置接口的反向代理

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
server {
listen 80;
server_name a.com;
root /wwwroot/test;
autoindex off;
index index.html index.htm index.php;

# 将a.com/api的所有请求反向代理到b.com
location /open/api {
proxy_pass http://b.com;
}

location ~ /\.ht {
deny all;
}
}
HyruleTeam wechat
前端手艺工坊